Documentation
¶
Index ¶
- Constants
- func Find(tasks []Task, id string) (int, error)
- func IsDue(t Task, now time.Time) bool
- func IsOneTime(sched string) bool
- func NextAttempt(t Task, now time.Time) time.Time
- func NextRun(t Task, now time.Time) time.Time
- func OnceTime(sched string) (time.Time, bool)
- func Relative(next, now time.Time) string
- func RunGate(ctx context.Context, dir, script string) (bool, string, error)
- func Tools(store Store) []tool.Tool
- type FileStore
- type MemoryStore
- type Store
- type Task
Constants ¶
const ( StatusActive = "active" StatusPaused = "paused" // MinInterval is a floor against runaway wake loops, not a technical // limit: every fire is a model turn, so tighter polling belongs in a // pre-check script or a backgrounded watcher, not the schedule itself. // Checked when a task is created, not when an existing one is evaluated. MinInterval = 10 * time.Second MaxJitter = 15 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func Find ¶
Find resolves a task reference the model typed back: an exact id, or an unambiguous prefix of one. Ambiguous prefixes are an error rather than a coin flip on which task gets paused or removed.
func NextAttempt ¶
NextAttempt is NextRun pushed out by failure backoff: consecutive pre-check failures space retries exponentially (2m, 4m, ... capped at an hour) so a broken gate on a tight interval cannot wake-loop the agent.
func Relative ¶
Relative renders a next-run time the way every surface shows it: "overdue", "in 42m", "in 3h5m".
Types ¶
type FileStore ¶
type FileStore struct {
// contains filtered or unexported fields
}
func NewFileStore ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore() *MemoryStore
func (*MemoryStore) Changed ¶
func (s *MemoryStore) Changed() <-chan struct{}
Changed signals (coalesced, one buffered tick) after every successful Mutate, so a scheduler sleeping until the next known due time can wake up and re-plan when tasks are added or removed mid-sleep.
func (*MemoryStore) List ¶
func (s *MemoryStore) List() ([]Task, error)
type Store ¶
Store holds a set of scheduled tasks. FileStore persists them across restarts (the building block for durable schedules); MemoryStore is scoped to a single interactive session and dies with it.
type Task ¶
type Task struct {
ID string `yaml:"id"`
Prompt string `yaml:"prompt"`
Schedule string `yaml:"schedule"`
Script string `yaml:"script,omitempty"`
Status string `yaml:"status"`
CreatedAt time.Time `yaml:"created_at"`
LastRun *time.Time `yaml:"last_run,omitempty"`
Failures int `yaml:"failures,omitempty"`
LastAttempt *time.Time `yaml:"last_attempt,omitempty"`
}