Documentation
¶
Index ¶
- func BindExecutable(s *Storage, dbPath string) error
- type Config
- type Event
- type EventPriority
- type FileRecord
- type Memory
- type Message
- type SessionMeta
- type Storage
- func (s *Storage) AddEvent(title, content string, priority EventPriority, channel string) (int64, error)
- func (s *Storage) AddFile(path, content, mimeType string) error
- func (s *Storage) AddMemory(text, category string, importance float64) (int64, error)
- func (s *Storage) AddMessage(sessionKey, role, content string) error
- func (s *Storage) ArchiveMessages(sessionKey string, beforeID int64) error
- func (s *Storage) ClearConfigSection(section string) error
- func (s *Storage) ClearMessages(sessionKey string) error
- func (s *Storage) ClearOldEvents(olderThanHours int) error
- func (s *Storage) Close() error
- func (s *Storage) ConfigExists(section string) (bool, error)
- func (s *Storage) DeleteConfig(section, key string) error
- func (s *Storage) DeleteMemory(key string) error
- func (s *Storage) DeleteMemoryByID(id int64) error
- func (s *Storage) Exec(query string, args ...interface{}) (interface{}, error)
- func (s *Storage) ExportConfig() ([]byte, error)
- func (s *Storage) ExportMemories() ([]byte, error)
- func (s *Storage) GetAllMemories(limit int) ([]Memory, error)
- func (s *Storage) GetConfig(section, key string) (string, error)
- func (s *Storage) GetConfigSection(section string) (map[string]string, error)
- func (s *Storage) GetEventCount() (map[string]int, error)
- func (s *Storage) GetFile(path string) (*FileRecord, error)
- func (s *Storage) GetMemoriesByCategory(category string) ([]Memory, error)
- func (s *Storage) GetMemory(idOrKey string) (Memory, error)
- func (s *Storage) GetMessages(sessionKey string, limit int) ([]Message, error)
- func (s *Storage) GetNextEvent() (*Event, error)
- func (s *Storage) GetPendingEvents(limit int) ([]Event, error)
- func (s *Storage) GetSessionMeta(sessionKey string) (SessionMeta, error)
- func (s *Storage) ImportMemory(key, value, category string) error
- func (s *Storage) ListFiles() ([]FileRecord, error)
- func (s *Storage) Query(query string, args ...interface{}) (interface{}, error)
- func (s *Storage) SearchMemories(keyword string) ([]Memory, error)
- func (s *Storage) SetConfig(section, key, value string) error
- func (s *Storage) SetMemory(key, text, category string) error
- func (s *Storage) Stats() (map[string]int, error)
- func (s *Storage) UpdateEventStatus(id int64, status string) error
- func (s *Storage) UpsertSessionMeta(meta SessionMeta) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindExecutable ¶
BindExecutable is a no-op when built without the binddb tag.
Types ¶
type Event ¶
type Event struct {
ID int64 `json:"id"`
Title string `json:"title"`
Content string `json:"content"`
Priority EventPriority `json:"priority"` // 0-3
Status string `json:"status"` // pending, processing, completed, dismissed
Channel string `json:"channel"` // telegram, discord, etc (empty = all)
CreatedAt time.Time `json:"created_at"`
ProcessedAt *time.Time `json:"processed_at,omitempty"`
}
type EventPriority ¶
type EventPriority int
EventPriority levels (lower = higher priority) 0 = Critical (broadcast to all channels immediately) 1 = Important (channel broadcast) 2 = Normal (process when idle) 3 = Low (process when available)
const ( PriorityCritical EventPriority = 0 // Broadcast to all channels PriorityHigh EventPriority = 1 // Broadcast to configured channels PriorityNormal EventPriority = 2 // Process when idle PriorityLow EventPriority = 3 // Process when available )
type FileRecord ¶
type Memory ¶
type Memory struct {
ID int64 `json:"id"`
Key string `json:"key"`
Text string `json:"text"` // memory content
Category string `json:"category"` // preference, decision, fact, entity, other
Importance float64 `json:"importance"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
type SessionMeta ¶
type SessionMeta struct {
SessionKey string `json:"session_key"`
TotalTokens int `json:"total_tokens"`
CompactionCount int `json:"compaction_count"`
LastSummary string `json:"last_summary"`
MemoryFlushAt time.Time `json:"memory_flush_at"`
MemoryFlushCompactionCnt int `json:"memory_flush_compaction_count"`
UpdatedAt time.Time `json:"updated_at"`
}
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func (*Storage) AddEvent ¶
func (s *Storage) AddEvent(title, content string, priority EventPriority, channel string) (int64, error)
AddEvent adds a new event to the database
func (*Storage) AddMessage ¶
func (*Storage) ArchiveMessages ¶
func (*Storage) ClearConfigSection ¶
ClearConfigSection clears a section
func (*Storage) ClearMessages ¶
func (*Storage) ClearOldEvents ¶
ClearOldEvents removes completed/dismissed events older than specified hours
func (*Storage) ConfigExists ¶
ConfigExists checks whether a section exists
func (*Storage) DeleteConfig ¶
DeleteConfig deletes a config entry
func (*Storage) DeleteMemory ¶
func (*Storage) DeleteMemoryByID ¶
func (*Storage) ExportConfig ¶
ExportConfig exports all configs as JSON
func (*Storage) ExportMemories ¶
Export memories to JSON
func (*Storage) GetConfigSection ¶
GetConfigSection reads all config values in a section
func (*Storage) GetEventCount ¶
GetEventCount returns counts by status
func (*Storage) GetMemoriesByCategory ¶
func (*Storage) GetMessages ¶
func (*Storage) GetNextEvent ¶
GetNextEvent returns the highest priority pending event
func (*Storage) GetPendingEvents ¶
GetPendingEvents returns pending events ordered by priority (0 first)
func (*Storage) GetSessionMeta ¶
func (s *Storage) GetSessionMeta(sessionKey string) (SessionMeta, error)
func (*Storage) ImportMemory ¶
Import from MD-style data (simplified)
func (*Storage) ListFiles ¶
func (s *Storage) ListFiles() ([]FileRecord, error)
func (*Storage) UpdateEventStatus ¶
UpdateEventStatus updates an event's status
func (*Storage) UpsertSessionMeta ¶
func (s *Storage) UpsertSessionMeta(meta SessionMeta) error