store

package
v0.100.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// MetadataKeyLastAgent stores the last agent type for sticky routing.
	// Values: "memo", "schedule", "amazing", "geek", "evolution"
	MetadataKeyLastAgent = "last_agent"

	// MetadataKeyIntent stores the classified intent.
	// Values: "search", "create", "query", "edit", "delete", "unknown"
	MetadataKeyIntent = "intent"

	// MetadataKeyIntentConfidence stores the intent classification confidence (0-1).
	MetadataKeyIntentConfidence = "intent_confidence"

	// MetadataKeyRouteMethod stores how the routing decision was made.
	// Values: "cache", "rule", "llm", "sticky", "metadata_sticky"
	MetadataKeyRouteMethod = "route_method"

	// MetadataKeyStickyUntil stores the sticky window expiration timestamp (Unix seconds).
	MetadataKeyStickyUntil = "sticky_until"

	// MetadataKeyStickyCount stores the number of times sticky routing has been extended.
	MetadataKeyStickyCount = "sticky_count"

	// MetadataKeyTopics stores the conversation topics extracted from the block.
	// Values: []string{"schedule", "memo", "general"}
	MetadataKeyTopics = "topics"

	// MetadataKeyEntities stores extracted entities from the conversation.
	// Values: map[string]string{"date": "2024-01-15", "location": "Beijing"}
	MetadataKeyEntities = "entities"
)

Metadata key constants for AIBlock.Metadata field. These keys follow the context-engineering.md architecture for state management and sticky routing.

View Source
const (
	// MigrateFilePrefix is the prefix for migration files.
	// Migration files use timestamp format: YYYYMMDDHHMMSS_description.sql
	MigrateFilePrefix = ""
	// LatestSchemaFileName is the name of the latest schema file.
	// This file is used to initialize fresh installations with the current schema.
	LatestSchemaFileName = "LATEST.sql"
	// MigrateDirName is the subdirectory containing migration files.
	MigrateDirName = "migrate"
	// SchemaDirName is the subdirectory containing the base schema file.
	SchemaDirName = "schema"
)
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 AIBlock added in v0.94.0

type AIBlock struct {
	ID                 int64
	UID                string
	ConversationID     int32
	RoundNumber        int32
	BlockType          AIBlockType
	Mode               AIBlockMode
	UserInputs         []UserInput
	AssistantContent   string
	AssistantTimestamp int64
	EventStream        []BlockEvent
	SessionStats       *SessionStats
	CCSessionID        string
	Status             AIBlockStatus
	Metadata           map[string]any
	ParentBlockID      *int64 // Parent block ID for tree branching (null for root blocks)
	BranchPath         string // Branch path for ordering (e.g., "0/1/3")
	// Token usage statistics (P1-A006: LLM Stats Collection)
	TokenUsage *TokenUsage
	// Cost estimation (ai-block-fields-extension)
	CostEstimate      int64  // In milli-cents (1/1000 of a US cent)
	ModelVersion      string // LLM model used (e.g., "deepseek-chat")
	UserFeedback      string // User feedback: "thumbs_up", "thumbs_down", or custom
	RegenerationCount int32  // Number of times this block was regenerated
	ErrorMessage      string // Error message if status = ERROR
	ArchivedAt        *int64 // Timestamp when block was archived (null if active)
	CreatedTs         int64
	UpdatedTs         int64
}

AIBlock represents a conversation block (round)

func (*AIBlock) GetMetadataIntent added in v0.100.0

func (b *AIBlock) GetMetadataIntent() (string, bool)

GetMetadataIntent retrieves the intent from block metadata.

func (*AIBlock) GetMetadataIntentConfidence added in v0.100.0

func (b *AIBlock) GetMetadataIntentConfidence() (float32, bool)

GetMetadataIntentConfidence retrieves the intent confidence from block metadata.

func (*AIBlock) GetMetadataLastAgent added in v0.100.0

func (b *AIBlock) GetMetadataLastAgent() (string, bool)

GetMetadataLastAgent retrieves the last agent from block metadata.

func (*AIBlock) GetMetadataStickyUntil added in v0.100.0

func (b *AIBlock) GetMetadataStickyUntil() (int64, bool)

GetMetadataStickyUntil retrieves the sticky expiration timestamp.

type AIBlockMode added in v0.94.0

type AIBlockMode string

AIBlockMode represents the AI mode

const (
	AIBlockModeNormal    AIBlockMode = "normal"
	AIBlockModeGeek      AIBlockMode = "geek"
	AIBlockModeEvolution AIBlockMode = "evolution"
)

type AIBlockStatus added in v0.94.0

type AIBlockStatus string

AIBlockStatus represents the block status

const (
	AIBlockStatusPending   AIBlockStatus = "pending"
	AIBlockStatusStreaming AIBlockStatus = "streaming"
	AIBlockStatusCompleted AIBlockStatus = "completed"
	AIBlockStatusError     AIBlockStatus = "error"
)

type AIBlockStore added in v0.94.0

type AIBlockStore interface {
	// CreateAIBlock creates a new block
	CreateAIBlock(ctx context.Context, create *CreateAIBlock) (*AIBlock, error)

	// GetAIBlock retrieves a block by ID
	GetAIBlock(ctx context.Context, id int64) (*AIBlock, error)

	// ListAIBlocks retrieves blocks for a conversation
	ListAIBlocks(ctx context.Context, find *FindAIBlock) ([]*AIBlock, error)

	// UpdateAIBlock updates a block
	UpdateAIBlock(ctx context.Context, update *UpdateAIBlock) (*AIBlock, error)

	// AppendUserInput appends a user input to an existing block
	AppendUserInput(ctx context.Context, blockID int64, input UserInput) error

	// AppendEvent appends an event to the event stream
	AppendEvent(ctx context.Context, blockID int64, event BlockEvent) error

	// AppendEventsBatch appends multiple events to the event stream in a single query
	AppendEventsBatch(ctx context.Context, blockID int64, events []BlockEvent) error

	// UpdateAIBlockStatus updates the block status
	UpdateAIBlockStatus(ctx context.Context, blockID int64, status AIBlockStatus) error

	// DeleteAIBlock deletes a block
	DeleteAIBlock(ctx context.Context, id int64) error

	// GetLatestAIBlock retrieves the latest block for a conversation
	GetLatestAIBlock(ctx context.Context, conversationID int32) (*AIBlock, error)

	// GetPendingAIBlocks retrieves all pending/streaming blocks for cleanup
	GetPendingAIBlocks(ctx context.Context) ([]*AIBlock, error)

	// ForkBlock creates a new block as a branch from an existing block.
	// The new block inherits the parent's conversation. User inputs can be optionally replaced.
	// If replaceUserInputs is nil, inherits parent's user inputs.
	// If replaceUserInputs is provided, uses the new user inputs (for message editing).
	ForkBlock(ctx context.Context, parentID int64, reason string, replaceUserInputs []UserInput) (*AIBlock, error)

	// ListChildBlocks lists all direct children of a block.
	ListChildBlocks(ctx context.Context, parentID int64) ([]*AIBlock, error)

	// GetActivePath retrieves the currently active branch path for a conversation.
	GetActivePath(ctx context.Context, conversationID int32) ([]*AIBlock, error)

	// DeleteBranch deletes a block and all its descendants.
	DeleteBranch(ctx context.Context, blockID int64, cascade bool) error

	// ArchiveInactiveBranches archives blocks not on the active branch path.
	// This sets archived_at timestamp for blocks that don't match the target path.
	ArchiveInactiveBranches(ctx context.Context, conversationID int32, targetPath string, archivedAt int64) error
}

AIBlockStore defines the interface for block storage operations P0 fix: align method names with Driver interface for compatibility

type AIBlockType added in v0.94.0

type AIBlockType string

AIBlockType represents the block type

const (
	AIBlockTypeMessage          AIBlockType = "message"
	AIBlockTypeContextSeparator AIBlockType = "context_separator"
)

type AIConversation

type AIConversation struct {
	UID         string
	Title       string
	TitleSource TitleSource // Indicates how the title was created
	ParrotID    string
	RowStatus   RowStatus
	CreatedTs   int64
	UpdatedTs   int64
	ID          int32
	CreatorID   int32
	Pinned      bool
	BlockCount  int32 // Number of blocks in this conversation (populated by ListAIConversations with JOIN)
}

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 AgentSessionStats added in v0.93.0

type AgentSessionStats struct {
	ID                   int64
	SessionID            string
	ConversationID       int64
	UserID               int32
	AgentType            string
	StartedAt            time.Time
	EndedAt              time.Time
	TotalDurationMs      int64
	ThinkingDurationMs   int64
	ToolDurationMs       int64
	GenerationDurationMs int64
	InputTokens          int32
	OutputTokens         int32
	CacheWriteTokens     int32
	CacheReadTokens      int32
	TotalTokens          int32
	TotalCostUSD         float64
	ToolCallCount        int32
	ToolsUsed            []string
	FilesModified        int32
	FilePaths            []string
	ModelUsed            string
	IsError              bool
	ErrorMessage         string
	CreatedAt            time.Time
	UpdatedAt            time.Time
}

AgentSessionStats represents a session statistics record for storage. AgentSessionStats 表示会话统计数据的存储记录。

type AgentStatsStore added in v0.93.0

type AgentStatsStore interface {
	// SaveSessionStats saves a session statistics record.
	SaveSessionStats(ctx context.Context, stats *AgentSessionStats) error

	// GetSessionStats retrieves stats by session ID.
	GetSessionStats(ctx context.Context, sessionID string) (*AgentSessionStats, error)

	// ListSessionStats retrieves stats for a user with pagination.
	ListSessionStats(ctx context.Context, userID int32, limit, offset int) ([]*AgentSessionStats, int64, error)

	// GetDailyCostUsage retrieves total cost for a user in a date range.
	GetDailyCostUsage(ctx context.Context, userID int32, startDate, endDate time.Time) (float64, error)

	// GetCostStats retrieves aggregated cost statistics.
	GetCostStats(ctx context.Context, userID int32, days int) (*CostStats, error)

	// GetUserCostSettings retrieves or creates user cost settings.
	GetUserCostSettings(ctx context.Context, userID int32) (*UserCostSettings, error)

	// SetUserCostSettings updates user cost settings.
	SetUserCostSettings(ctx context.Context, settings *UserCostSettings) error
}

AgentStatsStore defines the interface for session statistics persistence. AgentStatsStore 定义会话统计持久化的接口。

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 BlockEvent added in v0.94.0

type BlockEvent struct {
	Type      string         `json:"type"` // "thinking", "tool_use", "tool_result", "answer", "error"
	Content   string         `json:"content,omitempty"`
	Timestamp int64          `json:"timestamp"`
	Meta      map[string]any `json:"meta,omitempty"`
}

BlockEvent represents an event in the event stream

type CostStats added in v0.93.0

type CostStats struct {
	TotalCostUSD         float64
	DailyAverageUSD      float64
	SessionCount         int64
	MostExpensiveSession *AgentSessionStats
	DailyBreakdown       []*DailyCostData
}

CostStats represents aggregated cost statistics for a user. CostStats 表示用户的聚合成本统计。

type CreateAIBlock added in v0.94.0

type CreateAIBlock struct {
	UID            string
	ConversationID int32
	BlockType      AIBlockType
	Mode           AIBlockMode
	UserInputs     []UserInput
	Metadata       map[string]any
	CCSessionID    string
	Status         AIBlockStatus
	ParentBlockID  *int64 // Parent block ID for forking (null for new root)
	// New fields for block extensions
	TokenUsage   *TokenUsage
	CostEstimate int64
	ModelVersion string
	CreatedTs    int64
	UpdatedTs    int64
}

CreateAIBlock represents the input for creating a block

type CreateRouterFeedback added in v0.94.0

type CreateRouterFeedback struct {
	UserID    int32
	Input     string
	Predicted string
	Actual    string
	Feedback  string
	Timestamp int64
	Source    string
}

CreateRouterFeedback specifies data for creating a router feedback entry.

type DailyCostData added in v0.93.0

type DailyCostData struct {
	Date         string // YYYY-MM-DD
	CostUSD      float64
	SessionCount int64
}

DailyCostData represents cost data for a single day. DailyCostData 表示单日的成本数据。

type DeleteAIConversation

type DeleteAIConversation struct {
	ID 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)

	// MemoSummary model related methods.
	UpsertMemoSummary(ctx context.Context, upsert *UpsertMemoSummary) (*MemoSummary, error)
	ListMemoSummarys(ctx context.Context, find *FindMemoSummary) ([]*MemoSummary, error)
	DeleteMemoSummary(ctx context.Context, memoID int32) error
	FindMemosWithoutSummary(ctx context.Context, limit int) ([]*Memo, error)

	// MemoTag model related methods.
	UpsertMemoTag(ctx context.Context, upsert *UpsertMemoTag) (*MemoTag, error)
	UpsertMemoTags(ctx context.Context, upserts []*UpsertMemoTag) error
	ListMemoTags(ctx context.Context, find *FindMemoTag) ([]*MemoTag, error)
	DeleteMemoTag(ctx context.Context, memoID int32, tag string) error
	DeleteAllMemoTags(ctx context.Context, memoID int32) 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

	// AIBlock model related methods (Unified Block Model).
	CreateAIBlock(ctx context.Context, create *CreateAIBlock) (*AIBlock, error)
	GetAIBlock(ctx context.Context, id int64) (*AIBlock, error)
	ListAIBlocks(ctx context.Context, find *FindAIBlock) ([]*AIBlock, error)
	UpdateAIBlock(ctx context.Context, update *UpdateAIBlock) (*AIBlock, error)
	DeleteAIBlock(ctx context.Context, id int64) error
	AppendUserInput(ctx context.Context, blockID int64, input UserInput) error
	AppendEvent(ctx context.Context, blockID int64, event BlockEvent) error
	AppendEventsBatch(ctx context.Context, blockID int64, events []BlockEvent) error
	UpdateAIBlockStatus(ctx context.Context, blockID int64, status AIBlockStatus) error
	GetLatestAIBlock(ctx context.Context, conversationID int32) (*AIBlock, error)
	GetPendingAIBlocks(ctx context.Context) ([]*AIBlock, error)
	CreateAIBlockWithRound(ctx context.Context, create *CreateAIBlock) (*AIBlock, error)

	// CompleteBlock atomically marks a block as completed with content and stats.
	CompleteBlock(ctx context.Context, blockID int64, assistantContent string, sessionStats *SessionStats) 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

	// EpisodicMemoryEmbedding model related methods.
	UpsertEpisodicMemoryEmbedding(ctx context.Context, embedding *EpisodicMemoryEmbedding) (*EpisodicMemoryEmbedding, error)
	ListEpisodicMemoryEmbeddings(ctx context.Context, find *FindEpisodicMemoryEmbedding) ([]*EpisodicMemoryEmbedding, error)
	DeleteEpisodicMemoryEmbedding(ctx context.Context, episodicMemoryID int32) error
	FindEpisodicMemoriesWithoutEmbedding(ctx context.Context, find *FindEpisodicMemoriesWithoutEmbedding) ([]*EpisodicMemory, error)
	EpisodicVectorSearch(ctx context.Context, opts *EpisodicVectorSearchOptions) ([]*EpisodicMemoryWithScore, 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

	// ========== Tree Branching Methods (tree-conversation-branching) ==========
	// ForkBlock creates a new block as a branch from an existing block.
	// The new block inherits the parent's conversation. User inputs can be optionally replaced.
	// If replaceUserInputs is nil, inherits parent's user inputs.
	// If replaceUserInputs is provided, uses the new user inputs (for message editing).
	ForkBlock(ctx context.Context, parentID int64, reason string, replaceUserInputs []UserInput) (*AIBlock, error)
	// ListChildBlocks lists all direct children of a block.
	ListChildBlocks(ctx context.Context, parentID int64) ([]*AIBlock, error)
	// GetActivePath retrieves the currently active branch path for a conversation.
	GetActivePath(ctx context.Context, conversationID int32) ([]*AIBlock, error)
	// DeleteBranch deletes a block and all its descendants.
	DeleteBranch(ctx context.Context, blockID int64, cascade bool) error
	// ArchiveInactiveBranches archives blocks not on the active branch path.
	ArchiveInactiveBranches(ctx context.Context, conversationID int32, targetPath string, archivedAt int64) error

	// AgentStatsStore provides session statistics persistence.
	AgentStatsStore() AgentStatsStore

	// SecurityAuditStore provides security audit logging.
	SecurityAuditStore() SecurityAuditStore
}

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 EpisodicMemoryEmbedding added in v0.100.0

type EpisodicMemoryEmbedding struct {
	ID               int32
	EpisodicMemoryID int32
	Model            string
	Embedding        []float32
	CreatedTs        int64
	UpdatedTs        int64
}

EpisodicMemoryEmbedding represents the vector embedding of an episodic memory.

type EpisodicMemoryWithScore added in v0.100.0

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

EpisodicMemoryWithScore represents a vector search result with similarity score.

type EpisodicVectorSearchOptions added in v0.100.0

type EpisodicVectorSearchOptions struct {
	Vector       []float32
	Limit        int
	UserID       int32
	AgentType    *string // Optional: filter by agent type
	CreatedAfter int64   // Optional: only search memories created after this timestamp
}

EpisodicVectorSearchOptions represents the options for episodic memory vector search.

func (*EpisodicVectorSearchOptions) Validate added in v0.100.0

func (o *EpisodicVectorSearchOptions) Validate() error

Validate validates the EpisodicVectorSearchOptions.

type FindAIBlock added in v0.94.0

type FindAIBlock struct {
	ID             *int64
	UID            *string
	ConversationID *int32
	Status         *AIBlockStatus
	Mode           *AIBlockMode
	CCSessionID    *string
	ParentBlockID  *int64 // Filter by parent block (for branch queries)
}

FindAIBlock represents the filter for finding blocks

type FindAIConversation

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

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 FindEpisodicMemoriesWithoutEmbedding added in v0.100.0

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

FindEpisodicMemoriesWithoutEmbedding is the find condition for episodic memories without embeddings.

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 FindEpisodicMemoryEmbedding added in v0.100.0

type FindEpisodicMemoryEmbedding struct {
	EpisodicMemoryID *int32
	Model            *string
}

FindEpisodicMemoryEmbedding is the find condition for episodic memory embeddings.

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 FindMemoSummary added in v0.100.0

type FindMemoSummary struct {
	MemoID *int32
	ID     *int32
	Limit  *int
	Offset *int
	Status *MemoSummaryStatus
}

FindMemoSummary is the find condition for memo summaries.

type FindMemoTag added in v0.100.0

type FindMemoTag struct {
	MemoID *int32
	Tag    *string
	Limit  *int
	Offset *int
}

FindMemoTag is the find condition for memo tags.

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 FindRouterFeedback added in v0.94.0

type FindRouterFeedback struct {
	UserID    *int32
	StartTime *int64
	EndTime   *int64
	Feedback  *string
	Limit     int
}

FindRouterFeedback specifies conditions for finding router feedback.

type FindRouterWeight added in v0.94.0

type FindRouterWeight struct {
	UserID   *int32
	Category *string
}

FindRouterWeight specifies conditions for finding router weights.

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 GetRouterStats added in v0.94.0

type GetRouterStats struct {
	UserID    int32
	TimeRange time.Duration
}

GetRouterStats specifies parameters for router statistics.

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 MemoSummary added in v0.100.0

type MemoSummary struct {
	ID           int32
	MemoID       int32
	Summary      string
	Status       MemoSummaryStatus
	ErrorMessage *string
	CreatedTs    int64
	UpdatedTs    int64
}

MemoSummary represents the AI-generated summary of a memo.

type MemoSummaryStatus added in v0.100.0

type MemoSummaryStatus string

MemoSummaryStatus represents the generation status of a memo summary.

const (
	// MemoSummaryStatusPending means the summary has not been generated yet.
	MemoSummaryStatusPending MemoSummaryStatus = "PENDING"
	// MemoSummaryStatusGenerating means the summary is being generated.
	MemoSummaryStatusGenerating MemoSummaryStatus = "GENERATING"
	// MemoSummaryStatusCompleted means the summary has been generated successfully.
	MemoSummaryStatusCompleted MemoSummaryStatus = "COMPLETED"
	// MemoSummaryStatusFailed means the summary generation failed.
	MemoSummaryStatusFailed MemoSummaryStatus = "FAILED"
)

type MemoTag added in v0.100.0

type MemoTag struct {
	ID         int32
	MemoID     int32
	Tag        string
	Confidence float32
	Source     MemoTagSource
	CreatedTs  int64
}

MemoTag represents a tag associated with a memo.

type MemoTagSource added in v0.100.0

type MemoTagSource string

MemoTagSource represents the source of a tag.

const (
	// MemoTagSourceLLM is the LLM-generated tag source.
	MemoTagSourceLLM MemoTagSource = "llm"
	// MemoTagSourceRules is the rule-based tag source.
	MemoTagSourceRules MemoTagSource = "rules"
	// MemoTagSourceStatistics is the statistics-based tag source.
	MemoTagSourceStatistics MemoTagSource = "statistics"
	// MemoTagSourceUser is the user-provided tag source.
	MemoTagSourceUser MemoTagSource = "user"
)

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 RouterFeedback added in v0.94.0

type RouterFeedback struct {
	ID        int64  `json:"id"`
	UserID    int32  `json:"user_id"`
	Input     string `json:"input"`
	Predicted string `json:"predicted"` // What the router predicted (as Intent string)
	Actual    string `json:"actual"`    // What the user actually wanted
	Feedback  string `json:"feedback"`  // FeedbackType: positive, rephrase, switch
	Timestamp int64  `json:"timestamp"`
	Source    string `json:"source"` // "rule", "history", "llm"
}

RouterFeedback represents a single feedback event for a routing decision.

type RouterStats added in v0.94.0

type RouterStats struct {
	TotalPredictions int64            `json:"total_predictions"`
	CorrectCount     int64            `json:"correct_count"`
	IncorrectCount   int64            `json:"incorrect_count"`
	Accuracy         float64          `json:"accuracy"`
	ByIntent         map[string]int64 `json:"by_intent"`
	BySource         map[string]int64 `json:"by_source"`
	LastUpdated      int64            `json:"last_updated"`
}

RouterStats represents routing accuracy statistics.

type RouterWeight added in v0.94.0

type RouterWeight struct {
	UserID    int32  `json:"user_id"`
	Category  string `json:"category"` // "schedule", "memo", "amazing"
	Keyword   string `json:"keyword"`
	Weight    int    `json:"weight"`
	CreatedTs int64  `json:"created_ts"`
	UpdatedTs int64  `json:"updated_ts"`
}

RouterWeight represents a weight adjustment for a keyword.

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 SecurityAuditEvent added in v0.93.0

type SecurityAuditEvent struct {
	ID                    int64
	SessionID             string
	UserID                int32
	AgentType             string
	OperationType         string
	OperationName         string
	RiskLevel             string
	CommandInput          string
	CommandMatchedPattern string
	ActionTaken           string
	Reason                string
	FilePath              string
	ToolID                string
	OccurredAt            time.Time
}

SecurityAuditEvent represents a security-related event for audit logging. SecurityAuditEvent 表示安全相关事件的审计日志。

type SecurityAuditStore added in v0.93.0

type SecurityAuditStore interface {
	// LogSecurityEvent saves a security event.
	LogSecurityEvent(ctx context.Context, event *SecurityAuditEvent) error

	// ListSecurityEvents retrieves security events for a user with pagination.
	ListSecurityEvents(ctx context.Context, userID int32, limit, offset int) ([]*SecurityAuditEvent, int64, error)

	// ListSecurityEventsByRisk retrieves events filtered by risk level.
	ListSecurityEventsByRisk(ctx context.Context, userID int32, riskLevel string, limit, offset int) ([]*SecurityAuditEvent, int64, error)
}

SecurityAuditStore defines the interface for security audit logging. SecurityAuditStore 定义安全审计日志的接口。

type SessionStats added in v0.94.0

type SessionStats struct {
	SessionID            string   `json:"session_id"`
	UserID               int32    `json:"user_id"`
	AgentType            string   `json:"agent_type"`
	TotalDurationMs      int64    `json:"total_duration_ms"`
	ThinkingDurationMs   int64    `json:"thinking_duration_ms"`
	ToolDurationMs       int64    `json:"tool_duration_ms"`
	GenerationDurationMs int64    `json:"generation_duration_ms"`
	InputTokens          int      `json:"input_tokens"`
	OutputTokens         int      `json:"output_tokens"`
	CacheWriteTokens     int      `json:"cache_write_tokens"`
	CacheReadTokens      int      `json:"cache_read_tokens"`
	TotalTokens          int      `json:"total_tokens"`
	TotalCostUsd         float64  `json:"total_cost_usd"`
	ToolCallCount        int      `json:"tool_call_count"`
	ToolsUsed            []string `json:"tools_used,omitempty"`
	FilesModified        int      `json:"files_modified"`
	FilePaths            []string `json:"file_paths,omitempty"`
	ModelUsed            string   `json:"model_used,omitempty"`
	IsError              bool     `json:"is_error"`
	ErrorMessage         string   `json:"error_message,omitempty"`
}

SessionStats represents session statistics (compatible with agent_session_stats)

type Store

type Store struct {

	// Store services
	AgentStatsStore    AgentStatsStore    // session statistics persistence
	SecurityAuditStore SecurityAuditStore // security audit logging
	// 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) AppendEvent added in v0.94.0

func (s *Store) AppendEvent(ctx context.Context, blockID int64, event BlockEvent) error

func (*Store) AppendEventsBatch added in v0.94.0

func (s *Store) AppendEventsBatch(ctx context.Context, blockID int64, events []BlockEvent) error

func (*Store) AppendUserInput added in v0.94.0

func (s *Store) AppendUserInput(ctx context.Context, blockID int64, input UserInput) error

func (*Store) ArchiveInactiveBranches added in v0.94.0

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

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) CompleteBlock added in v0.94.0

func (s *Store) CompleteBlock(ctx context.Context, blockID int64, assistantContent string, sessionStats *SessionStats) error

func (*Store) CreateAIBlock added in v0.94.0

func (s *Store) CreateAIBlock(ctx context.Context, create *CreateAIBlock) (*AIBlock, error)

AIBlock methods (Unified Block Model). AIMessage functions removed: ALL IN Block!

func (*Store) CreateAIBlockWithRound added in v0.94.0

func (s *Store) CreateAIBlockWithRound(ctx context.Context, create *CreateAIBlock) (*AIBlock, error)

func (*Store) CreateAIConversation

func (s *Store) CreateAIConversation(ctx context.Context, create *AIConversation) (*AIConversation, 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) DeleteAIBlock added in v0.94.0

func (s *Store) DeleteAIBlock(ctx context.Context, id int64) error

func (*Store) DeleteAIConversation

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

func (*Store) DeleteAgentMetrics

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

func (*Store) DeleteAllMemoTags added in v0.100.0

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

DeleteAllMemoTags deletes all tags for a memo.

func (*Store) DeleteAttachment

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

func (*Store) DeleteBranch added in v0.94.0

func (s *Store) DeleteBranch(ctx context.Context, blockID int64, cascade bool) error

func (*Store) DeleteEpisodicMemory

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

func (*Store) DeleteEpisodicMemoryEmbedding added in v0.100.0

func (s *Store) DeleteEpisodicMemoryEmbedding(ctx context.Context, episodicMemoryID int32) error

DeleteEpisodicMemoryEmbedding deletes an episodic memory embedding.

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) DeleteMemoSummary added in v0.100.0

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

DeleteMemoSummary deletes a memo summary.

func (*Store) DeleteMemoTag added in v0.100.0

func (s *Store) DeleteMemoTag(ctx context.Context, memoID int32, tag string) error

DeleteMemoTag deletes a memo tag.

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) EpisodicVectorSearch added in v0.100.0

func (s *Store) EpisodicVectorSearch(ctx context.Context, opts *EpisodicVectorSearchOptions) ([]*EpisodicMemoryWithScore, error)

EpisodicVectorSearch performs vector similarity search on episodic memories.

func (*Store) FindEpisodicMemoriesWithoutEmbedding added in v0.100.0

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

FindEpisodicMemoriesWithoutEmbedding finds episodic memories that don't have embeddings for the specified model.

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) FindMemosWithoutSummary added in v0.100.0

func (s *Store) FindMemosWithoutSummary(ctx context.Context, limit int) ([]*Memo, error)

FindMemosWithoutSummary finds memos that don't have summaries.

func (*Store) ForkBlock added in v0.94.0

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

func (*Store) GetAIBlock added in v0.94.0

func (s *Store) GetAIBlock(ctx context.Context, id int64) (*AIBlock, error)

func (*Store) GetActivePath added in v0.94.0

func (s *Store) GetActivePath(ctx context.Context, conversationID int32) ([]*AIBlock, error)

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) GetEpisodicMemoryEmbedding added in v0.100.0

func (s *Store) GetEpisodicMemoryEmbedding(ctx context.Context, episodicMemoryID int32, model string) (*EpisodicMemoryEmbedding, error)

GetEpisodicMemoryEmbedding gets the embedding of a specific episodic memory.

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) GetLatestAIBlock added in v0.94.0

func (s *Store) GetLatestAIBlock(ctx context.Context, conversationID int32) (*AIBlock, 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) GetMemoSummary added in v0.100.0

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

GetMemoSummary gets the summary of a specific memo.

func (*Store) GetPendingAIBlocks added in v0.94.0

func (s *Store) GetPendingAIBlocks(ctx context.Context) ([]*AIBlock, error)

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) ListAIBlocks added in v0.94.0

func (s *Store) ListAIBlocks(ctx context.Context, find *FindAIBlock) ([]*AIBlock, error)

func (*Store) ListAIConversations

func (s *Store) ListAIConversations(ctx context.Context, find *FindAIConversation) ([]*AIConversation, 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) ListChildBlocks added in v0.94.0

func (s *Store) ListChildBlocks(ctx context.Context, parentID int64) ([]*AIBlock, error)

func (*Store) ListEpisodicMemories

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

func (*Store) ListEpisodicMemoryEmbeddings added in v0.100.0

func (s *Store) ListEpisodicMemoryEmbeddings(ctx context.Context, find *FindEpisodicMemoryEmbedding) ([]*EpisodicMemoryEmbedding, error)

ListEpisodicMemoryEmbeddings lists episodic memory embeddings.

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) ListMemoSummarys added in v0.100.0

func (s *Store) ListMemoSummarys(ctx context.Context, find *FindMemoSummary) ([]*MemoSummary, error)

ListMemoSummarys lists memo summaries.

func (*Store) ListMemoTags added in v0.100.0

func (s *Store) ListMemoTags(ctx context.Context, find *FindMemoTag) ([]*MemoTag, error)

ListMemoTags lists memo tags.

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) UpdateAIBlock added in v0.94.0

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

func (*Store) UpdateAIBlockStatus added in v0.94.0

func (s *Store) UpdateAIBlockStatus(ctx context.Context, blockID int64, status AIBlockStatus) error

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) UpsertEpisodicMemoryEmbedding added in v0.100.0

func (s *Store) UpsertEpisodicMemoryEmbedding(ctx context.Context, embedding *EpisodicMemoryEmbedding) (*EpisodicMemoryEmbedding, error)

UpsertEpisodicMemoryEmbedding inserts or updates an episodic memory embedding.

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) UpsertMemoSummary added in v0.100.0

func (s *Store) UpsertMemoSummary(ctx context.Context, upsert *UpsertMemoSummary) (*MemoSummary, error)

UpsertMemoSummary inserts or updates a memo summary.

func (*Store) UpsertMemoTag added in v0.100.0

func (s *Store) UpsertMemoTag(ctx context.Context, upsert *UpsertMemoTag) (*MemoTag, error)

UpsertMemoTag inserts or updates a memo tag.

func (*Store) UpsertMemoTags added in v0.100.0

func (s *Store) UpsertMemoTags(ctx context.Context, upserts []*UpsertMemoTag) error

UpsertMemoTags inserts or updates multiple memo tags.

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 TitleSource added in v0.94.0

type TitleSource string

TitleSource indicates how the conversation title was created. - "default": System default (e.g., "New Chat" or truncated first message) - "auto": AI-generated title based on conversation content - "user": User-provided title (manual edit)

const (
	TitleSourceDefault TitleSource = "default"
	TitleSourceAuto    TitleSource = "auto"
	TitleSourceUser    TitleSource = "user"
)

type TokenUsage added in v0.94.0

type TokenUsage struct {
	PromptTokens     int32 `json:"prompt_tokens"`
	CompletionTokens int32 `json:"completion_tokens"`
	TotalTokens      int32 `json:"total_tokens"`
	CacheReadTokens  int32 `json:"cache_read_tokens,omitempty"`
	CacheWriteTokens int32 `json:"cache_write_tokens,omitempty"`
}

TokenUsage represents detailed token usage for a single block or LLM call. Added for P1-A006: LLM Stats Collection for Normal Mode.

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 UpdateAIBlock added in v0.94.0

type UpdateAIBlock struct {
	ID               int64
	UserInputs       *[]UserInput   // Replace user inputs
	AssistantContent *string        // Update AI response
	EventStream      *[]BlockEvent  // Replace event stream
	SessionStats     *SessionStats  // Update session stats
	CCSessionID      *string        // Update CC session ID
	Status           *AIBlockStatus // Update status
	Metadata         map[string]any // Merge metadata
	UpdatedTs        *int64         // Update timestamp
	// New fields for block extensions
	TokenUsage        *TokenUsage // Update token usage
	CostEstimate      *int64      // Update cost estimate
	ModelVersion      *string     // Update model version
	UserFeedback      *string     // Update user feedback
	RegenerationCount *int32      // Update regeneration count
	ErrorMessage      *string     // Update error message
	ArchivedAt        *int64      // Archive this block
}

UpdateAIBlock represents the input for updating a block

func (*UpdateAIBlock) SetMetadataIntent added in v0.100.0

func (u *UpdateAIBlock) SetMetadataIntent(intent string)

SetMetadataIntent sets the intent in update metadata.

func (*UpdateAIBlock) SetMetadataIntentConfidence added in v0.100.0

func (u *UpdateAIBlock) SetMetadataIntentConfidence(confidence float32)

SetMetadataIntentConfidence sets the intent confidence in update metadata.

func (*UpdateAIBlock) SetMetadataLastAgent added in v0.100.0

func (u *UpdateAIBlock) SetMetadataLastAgent(agent string)

SetMetadataLastAgent sets the last agent in update metadata.

func (*UpdateAIBlock) SetMetadataRouteMethod added in v0.100.0

func (u *UpdateAIBlock) SetMetadataRouteMethod(method string)

SetMetadataRouteMethod sets the routing method.

func (*UpdateAIBlock) SetMetadataStickyUntil added in v0.100.0

func (u *UpdateAIBlock) SetMetadataStickyUntil(unixSeconds int64)

SetMetadataStickyUntil sets the sticky expiration timestamp.

type UpdateAIConversation

type UpdateAIConversation struct {
	Title       *string
	TitleSource *TitleSource
	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 UpsertMemoSummary added in v0.100.0

type UpsertMemoSummary struct {
	MemoID       int32
	Summary      string
	Status       MemoSummaryStatus
	ErrorMessage *string
}

UpsertMemoSummary is the upsert condition for memo summary.

type UpsertMemoTag added in v0.100.0

type UpsertMemoTag struct {
	MemoID     int32
	Tag        string
	Confidence float32
	Source     MemoTagSource
}

UpsertMemoTag is the upsert condition for memo tag.

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 UpsertRouterWeight added in v0.94.0

type UpsertRouterWeight struct {
	UserID   int32
	Category string
	Keyword  string
	Weight   int
}

UpsertRouterWeight specifies data for upserting router weights.

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 UserCostSettings added in v0.93.0

type UserCostSettings struct {
	UserID                 int32
	DailyBudgetUSD         *float64 // NULL = unlimited
	PerSessionThresholdUSD float64
	AlertEnabled           bool
	AlertEmail             bool
	AlertInApp             bool
	BudgetResetAt          *time.Time
}

UserCostSettings represents user-specific cost control settings. UserCostSettings 表示用户特定的成本控制设置。

type UserInput added in v0.94.0

type UserInput struct {
	Content   string         `json:"content"`
	Timestamp int64          `json:"timestamp"`
	Metadata  map[string]any `json:"metadata,omitempty"`
}

UserInput represents a single user input in the block

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
	CreatedAfter  int64 // Optional: only search memos created after this timestamp
	MaxCandidates int   // Optional: maximum candidates to fetch (default: limit * 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

Directories

Path Synopsis
db

Jump to

Keyboard shortcuts

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