Documentation
¶
Index ¶
- func RunMigrations(ctx context.Context, sqlDB *sql.DB) error
- type Channel
- type MemoryFile
- type Message
- type RunStatus
- type SQLiteStore
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) CreateScheduledTask(ctx context.Context, task *ScheduledTask) (int64, error)
- func (s *SQLiteStore) DeleteChannel(ctx context.Context, channelID string) error
- func (s *SQLiteStore) DeleteChannelsByParentID(ctx context.Context, parentID string) error
- func (s *SQLiteStore) DeleteMemoryFile(ctx context.Context, filePath, dirPath string) error
- func (s *SQLiteStore) DeleteScheduledTask(ctx context.Context, id int64) error
- func (s *SQLiteStore) GetChannel(ctx context.Context, channelID string) (*Channel, error)
- func (s *SQLiteStore) GetChannelByDirPath(ctx context.Context, dirPath string, platform types.Platform) (*Channel, error)
- func (s *SQLiteStore) GetDueTasks(ctx context.Context, now time.Time) ([]*ScheduledTask, error)
- func (s *SQLiteStore) GetMemoryFileHash(ctx context.Context, filePath, dirPath string) (string, error)
- func (s *SQLiteStore) GetMemoryFilesByDirPath(ctx context.Context, dirPath string) ([]*MemoryFile, error)
- func (s *SQLiteStore) GetRecentMessages(ctx context.Context, channelID string, limit int) ([]*Message, error)
- func (s *SQLiteStore) GetScheduledTask(ctx context.Context, id int64) (*ScheduledTask, error)
- func (s *SQLiteStore) GetScheduledTaskByTemplateName(ctx context.Context, channelID, templateName string) (*ScheduledTask, error)
- func (s *SQLiteStore) InsertMessage(ctx context.Context, msg *Message) error
- func (s *SQLiteStore) InsertTaskRunLog(ctx context.Context, trl *TaskRunLog) (int64, error)
- func (s *SQLiteStore) IsChannelActive(ctx context.Context, channelID string) (bool, error)
- func (s *SQLiteStore) ListChannels(ctx context.Context) ([]*Channel, error)
- func (s *SQLiteStore) ListScheduledTasks(ctx context.Context, channelID string) ([]*ScheduledTask, error)
- func (s *SQLiteStore) MarkMessagesProcessed(ctx context.Context, ids []int64) error
- func (s *SQLiteStore) UpdateChannelPermissions(ctx context.Context, channelID string, perms types.Permissions) error
- func (s *SQLiteStore) UpdateScheduledTask(ctx context.Context, task *ScheduledTask) error
- func (s *SQLiteStore) UpdateScheduledTaskEnabled(ctx context.Context, id int64, enabled bool) error
- func (s *SQLiteStore) UpdateSessionID(ctx context.Context, channelID string, sessionID string) error
- func (s *SQLiteStore) UpdateTaskRunLog(ctx context.Context, trl *TaskRunLog) error
- func (s *SQLiteStore) UpsertChannel(ctx context.Context, ch *Channel) error
- func (s *SQLiteStore) UpsertMemoryFile(ctx context.Context, file *MemoryFile) error
- type ScheduledTask
- type Store
- type TaskRunLog
- type TaskType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Channel ¶
type Channel struct {
ID int64 `json:"id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
Name string `json:"name"`
DirPath string `json:"dir_path"`
ParentID string `json:"parent_id"`
Platform types.Platform `json:"platform"`
Active bool `json:"active"`
SessionID string `json:"session_id"`
Permissions types.Permissions `json:"permissions"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
Channel represents a chat platform channel where the bot operates.
type MemoryFile ¶ added in v0.1.33
type MemoryFile struct {
ID int64 `json:"id"`
FilePath string `json:"file_path"`
ChunkIndex int `json:"chunk_index"`
Content string `json:"content"`
ContentHash string `json:"content_hash"`
Embedding []byte `json:"embedding"`
Dimensions int `json:"dimensions"`
DirPath string `json:"dir_path"`
UpdatedAt time.Time `json:"updated_at"`
}
MemoryFile represents an indexed memory file (or chunk) with its embedding. ChunkIndex 0 is the header row (stores content_hash for the whole file). ChunkIndex 1+ are content chunks with embeddings for large files. Small files use a single row with ChunkIndex 0 that has both hash and embedding.
type Message ¶
type Message struct {
ID int64 `json:"id"`
ChatID int64 `json:"chat_id"`
ChannelID string `json:"channel_id"`
MsgID string `json:"msg_id"`
AuthorID string `json:"author_id"`
AuthorName string `json:"author_name"`
Content string `json:"content"`
IsBot bool `json:"is_bot"`
IsProcessed bool `json:"is_processed"`
CreatedAt time.Time `json:"created_at"`
}
Message represents a chat message stored for context.
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements Store using SQLite.
func NewSQLiteStore ¶
func NewSQLiteStore(dsn string) (*SQLiteStore, error)
NewSQLiteStore opens a SQLite database and returns a new SQLiteStore.
func NewSQLiteStoreFromDB ¶
func NewSQLiteStoreFromDB(sqlDB *sql.DB) *SQLiteStore
NewSQLiteStoreFromDB creates a SQLiteStore from an existing *sql.DB connection.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
func (*SQLiteStore) CreateScheduledTask ¶
func (s *SQLiteStore) CreateScheduledTask(ctx context.Context, task *ScheduledTask) (int64, error)
func (*SQLiteStore) DeleteChannel ¶ added in v0.1.12
func (s *SQLiteStore) DeleteChannel(ctx context.Context, channelID string) error
func (*SQLiteStore) DeleteChannelsByParentID ¶ added in v0.1.12
func (s *SQLiteStore) DeleteChannelsByParentID(ctx context.Context, parentID string) error
func (*SQLiteStore) DeleteMemoryFile ¶ added in v0.1.33
func (s *SQLiteStore) DeleteMemoryFile(ctx context.Context, filePath, dirPath string) error
func (*SQLiteStore) DeleteScheduledTask ¶
func (s *SQLiteStore) DeleteScheduledTask(ctx context.Context, id int64) error
func (*SQLiteStore) GetChannel ¶
func (*SQLiteStore) GetChannelByDirPath ¶
func (*SQLiteStore) GetDueTasks ¶
func (s *SQLiteStore) GetDueTasks(ctx context.Context, now time.Time) ([]*ScheduledTask, error)
func (*SQLiteStore) GetMemoryFileHash ¶ added in v0.1.33
func (*SQLiteStore) GetMemoryFilesByDirPath ¶ added in v0.1.33
func (s *SQLiteStore) GetMemoryFilesByDirPath(ctx context.Context, dirPath string) ([]*MemoryFile, error)
func (*SQLiteStore) GetRecentMessages ¶
func (*SQLiteStore) GetScheduledTask ¶
func (s *SQLiteStore) GetScheduledTask(ctx context.Context, id int64) (*ScheduledTask, error)
func (*SQLiteStore) GetScheduledTaskByTemplateName ¶
func (s *SQLiteStore) GetScheduledTaskByTemplateName(ctx context.Context, channelID, templateName string) (*ScheduledTask, error)
func (*SQLiteStore) InsertMessage ¶
func (s *SQLiteStore) InsertMessage(ctx context.Context, msg *Message) error
func (*SQLiteStore) InsertTaskRunLog ¶
func (s *SQLiteStore) InsertTaskRunLog(ctx context.Context, trl *TaskRunLog) (int64, error)
func (*SQLiteStore) IsChannelActive ¶
func (*SQLiteStore) ListChannels ¶ added in v0.1.15
func (s *SQLiteStore) ListChannels(ctx context.Context) ([]*Channel, error)
func (*SQLiteStore) ListScheduledTasks ¶
func (s *SQLiteStore) ListScheduledTasks(ctx context.Context, channelID string) ([]*ScheduledTask, error)
func (*SQLiteStore) MarkMessagesProcessed ¶
func (s *SQLiteStore) MarkMessagesProcessed(ctx context.Context, ids []int64) error
func (*SQLiteStore) UpdateChannelPermissions ¶ added in v0.1.41
func (s *SQLiteStore) UpdateChannelPermissions(ctx context.Context, channelID string, perms types.Permissions) error
func (*SQLiteStore) UpdateScheduledTask ¶
func (s *SQLiteStore) UpdateScheduledTask(ctx context.Context, task *ScheduledTask) error
func (*SQLiteStore) UpdateScheduledTaskEnabled ¶
func (*SQLiteStore) UpdateSessionID ¶
func (*SQLiteStore) UpdateTaskRunLog ¶
func (s *SQLiteStore) UpdateTaskRunLog(ctx context.Context, trl *TaskRunLog) error
func (*SQLiteStore) UpsertChannel ¶
func (s *SQLiteStore) UpsertChannel(ctx context.Context, ch *Channel) error
func (*SQLiteStore) UpsertMemoryFile ¶ added in v0.1.33
func (s *SQLiteStore) UpsertMemoryFile(ctx context.Context, file *MemoryFile) error
type ScheduledTask ¶
type ScheduledTask struct {
ID int64 `json:"id"`
ChannelID string `json:"channel_id"`
GuildID string `json:"guild_id"`
Schedule string `json:"schedule"`
Type TaskType `json:"type"`
Prompt string `json:"prompt"`
Enabled bool `json:"enabled"`
NextRunAt time.Time `json:"next_run_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
TemplateName string `json:"template_name"`
AutoDeleteSec int `json:"auto_delete_sec"`
}
ScheduledTask represents a task scheduled for execution.
type Store ¶
type Store interface {
UpsertChannel(ctx context.Context, ch *Channel) error
GetChannel(ctx context.Context, channelID string) (*Channel, error)
GetChannelByDirPath(ctx context.Context, dirPath string, platform types.Platform) (*Channel, error)
IsChannelActive(ctx context.Context, channelID string) (bool, error)
UpdateSessionID(ctx context.Context, channelID string, sessionID string) error
UpdateChannelPermissions(ctx context.Context, channelID string, perms types.Permissions) error
DeleteChannel(ctx context.Context, channelID string) error
DeleteChannelsByParentID(ctx context.Context, parentID string) error
InsertMessage(ctx context.Context, msg *Message) error
MarkMessagesProcessed(ctx context.Context, ids []int64) error
GetRecentMessages(ctx context.Context, channelID string, limit int) ([]*Message, error)
CreateScheduledTask(ctx context.Context, task *ScheduledTask) (int64, error)
GetDueTasks(ctx context.Context, now time.Time) ([]*ScheduledTask, error)
UpdateScheduledTask(ctx context.Context, task *ScheduledTask) error
DeleteScheduledTask(ctx context.Context, id int64) error
ListScheduledTasks(ctx context.Context, channelID string) ([]*ScheduledTask, error)
UpdateScheduledTaskEnabled(ctx context.Context, id int64, enabled bool) error
GetScheduledTask(ctx context.Context, id int64) (*ScheduledTask, error)
GetScheduledTaskByTemplateName(ctx context.Context, channelID, templateName string) (*ScheduledTask, error)
ListChannels(ctx context.Context) ([]*Channel, error)
InsertTaskRunLog(ctx context.Context, log *TaskRunLog) (int64, error)
UpdateTaskRunLog(ctx context.Context, log *TaskRunLog) error
UpsertMemoryFile(ctx context.Context, file *MemoryFile) error
GetMemoryFilesByDirPath(ctx context.Context, dirPath string) ([]*MemoryFile, error)
GetMemoryFileHash(ctx context.Context, filePath, dirPath string) (string, error)
DeleteMemoryFile(ctx context.Context, filePath, dirPath string) error
Close() error
}
Store defines all database operations.
type TaskRunLog ¶
type TaskRunLog struct {
ID int64 `json:"id"`
TaskID int64 `json:"task_id"`
Status RunStatus `json:"status"`
ResponseText string `json:"response_text"`
ErrorText string `json:"error_text"`
StartedAt time.Time `json:"started_at"`
FinishedAt time.Time `json:"finished_at"`
}
TaskRunLog records the execution history of a scheduled task.