Documentation
¶
Index ¶
- func MigrateWorkspaceJobs(oldStorePath, newSessionPath, workspaceDir string)
- func NextTime(expr string, from time.Time) (time.Time, error)
- type Job
- type Scheduler
- func (s *Scheduler) Create(cronExpr, prompt string, recurring bool, queueIfBusy bool) (Job, error)
- func (s *Scheduler) Delete(id string) bool
- func (s *Scheduler) DeleteWithError(id string) (bool, error)
- func (s *Scheduler) Get(id string) (Job, bool)
- func (s *Scheduler) List() []Job
- func (s *Scheduler) Load()
- func (s *Scheduler) SetEnqueue(fn func(prompt string, queueIfBusy bool))
- func (s *Scheduler) SetSession(storePath, oldStorePath, workspaceDir string)
- func (s *Scheduler) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MigrateWorkspaceJobs ¶ added in v1.3.100
func MigrateWorkspaceJobs(oldStorePath, newSessionPath, workspaceDir string)
MigrateWorkspaceJobs moves recurring jobs from the old workspace-scoped store file to the new per-session store file. It removes the migrated workspace bucket from the old file, ensuring each workspace's jobs are migrated exactly once (by the first instance that starts).
If oldStorePath doesn't exist, the workspace has no bucket, or the new store already exists, migration is a no-op.
func NextTime ¶
NextTime calculates the next time that matches the 5-field cron expression after the given 'from' time. Returns the next fire time or an error.
Supported syntax per field:
- * — any value
- */N — every Nth value
- N — exact value
- N,M,K — list of values
- N-M — range (inclusive)
- N-M/S — range with step
Types ¶
type Job ¶
type Job struct {
ID string
CronExpr string
Prompt string
Recurring bool
QueueIfBusy bool // if true, queue the prompt when agent is busy; if false (default), skip
CreatedAt time.Time
NextFire time.Time
}
Job represents a scheduled prompt job.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages cron-like prompt scheduling with optional persistence.
func NewScheduler ¶
NewScheduler creates a scheduler with the given enqueue callback and optional persistence path. If storePath is empty, no persistence is used (useful for tests).
func (*Scheduler) Create ¶
Create adds a new scheduled job and returns its snapshot. The cron expression is a standard 5-field format:
minute hour day-of-month month day-of-week
Supports: *, */N, N, N-M, N,M,K, N-M/S
func (*Scheduler) DeleteWithError ¶ added in v1.3.68
DeleteWithError removes a scheduled job by ID and reports persistence errors.
func (*Scheduler) Load ¶ added in v1.3.68
func (s *Scheduler) Load()
Load reads persisted recurring jobs for this session and schedules them. Must be called after NewScheduler, before any Create/Delete calls. If storePath is empty or the file doesn't exist, Load is a no-op.
func (*Scheduler) SetEnqueue ¶
SetEnqueue sets or replaces the enqueue callback. Use this when the scheduler is created before the TUI is available.
func (*Scheduler) SetSession ¶ added in v1.3.100
SetSession binds this scheduler to a session store path, migrating from the old workspace-scoped store if needed, then loading. This is used when the session ID is not yet known at scheduler creation time (e.g., TUI new session or desktop lazy init).
storePath is the per-session JSON file path. oldStorePath is the legacy cron-jobs.json path (empty to skip migration). workspaceDir is the working directory key for migration (empty to skip).