Documentation
¶
Overview ¶
Package store persists sessions and their messages in one sqlite file, the ledger everything else replays from. Pure Go driver, so the binary stays CGO-free.
Index ¶
- type Job
- type Run
- type Session
- type Store
- func (s *Store) AddJob(spec, prompt, channel, chat string) (int64, error)
- func (s *Store) Append(sessionID int64, msgs []provider.Message) error
- func (s *Store) Bind(channel, chat, session string) error
- func (s *Store) BindingFor(channel, chat string) (string, bool, error)
- func (s *Store) Close() error
- func (s *Store) EnabledJobs() ([]Job, error)
- func (s *Store) EnsureJob(label, spec, prompt, channel, chat string) (int64, error)
- func (s *Store) Jobs() ([]Job, error)
- func (s *Store) MarkRun(id int64, when time.Time) error
- func (s *Store) Messages(sessionID int64) ([]provider.Message, error)
- func (s *Store) RecordRun(jobID int64, when time.Time, ok bool, output string) error
- func (s *Store) RemoveJob(id int64) (bool, error)
- func (s *Store) Runs(limit int) ([]Run, error)
- func (s *Store) Session(name, channel string) (*Session, error)
- func (s *Store) Sessions() ([]Session, error)
- func (s *Store) SetJobEnabled(id int64, enabled bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
ID int64
Spec string
Prompt string
Channel string
Chat string
Enabled bool
LastRun time.Time
Created time.Time
Label string
}
Job is one scheduled prompt. LastRun is zero until it has run once. Label is empty for user jobs; a non-empty label marks a job the daemon owns and keeps unique, like the heartbeat.
type Session ¶
type Session struct {
ID int64
Name string
Channel string
Created time.Time
Updated time.Time
Messages int
}
Session is one conversation's row.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps the sqlite handle.
func (*Store) Bind ¶
Bind points a channel's chat at a named session, so the same conversation is reachable from more than one channel. Re-binding replaces the old target.
func (*Store) BindingFor ¶
BindingFor returns the session a chat is bound to, if any.
func (*Store) EnabledJobs ¶
EnabledJobs lists only the jobs the scheduler should consider.
func (*Store) EnsureJob ¶
EnsureJob upserts a labelled job the daemon owns, keyed on label. On first call it inserts and returns the new id; later it refreshes the spec, prompt, channel, and chat so config changes take effect without duplicating the job. It never resets last_run, so catch-up still works across restarts.
func (*Store) MarkRun ¶
MarkRun records that a job ran at the given time, so the next due time is computed from here. Setting it to now collapses any missed ticks into one.